/* 
    Squirrel open project
    Copyright (C) 2012  Elias Aran Paul Farhan
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include<utility/utility.hpp>

Point string2point(std::string pair)
{
	int size = pair.size();
	char first[size];
	char second[size];
    int i = 0;
    int state = 0;
    for (std::string::iterator it = pair.begin(); it != pair.end(); it++)
    {
		if(*it == '(')
		{
			state = 1;
		}
		else if(*it == ',')
		{
			state = 2;
			first[i]='\0';
			i = 0;
		}
		else if(*it ==')')
		{
			second[i]='\0';
			break;
		}
		else if(state == 1)
		{
			first[i] = *it;
			i++;
		}
		else if(state == 2)
		{
			second[i] = *it;
			i++;
		}
	}
	int one = atoi(first);
	int two = atoi(second);
	return std::make_pair(one, two);
}


